package com.example.takeaways.controller;


import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.example.takeaways.common.R;
import com.example.takeaways.entity.Orders;
import com.example.takeaways.service.OrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 * 订单明细表 前端控制器
 * </p>
 *
 * @author example
 * @since 2024-10-09
 */
@RestController
@RequestMapping("/order-detail")
public class OrderDetailController {
    @Autowired
    private OrderService orderService;


    @PutMapping("/status/1")
    public R<String> updateStatusStart1(Long ids){
        Orders orders=orderService.getById(ids);
        orders.setStatus(1);
        LambdaQueryWrapper<Orders> lambdaQueryWrapper = new LambdaQueryWrapper<>();
        lambdaQueryWrapper.eq(Orders::getId, ids);
        orderService.update(orders, lambdaQueryWrapper);
        return R.success("更新成功");
    }
    @PutMapping("/status/2")
    public R<String> updateStatusStart(Long ids){
        Orders orders=orderService.getById(ids);
        orders.setStatus(2);
        LambdaQueryWrapper<Orders> lambdaQueryWrapper = new LambdaQueryWrapper<>();
        lambdaQueryWrapper.eq(Orders::getId, ids);
        orderService.update(orders, lambdaQueryWrapper);
        return R.success("更新成功");
    }
}
